package com.brzjomo.secretiveworld.init;

import com.brzjomo.secretiveworld.SecretiveWorld;
import com.brzjomo.secretiveworld.world.biome.MermaidOcean;
import com.brzjomo.secretiveworld.world.biome.StillForest;

import net.minecraft.block.Blocks;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.biome.Biome.RainType;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModBiomeTypes {

	public static final DeferredRegister<Biome> BIOMES = new DeferredRegister<>(ForgeRegistries.BIOMES,
			SecretiveWorld.MODID);

	public static final RegistryObject<Biome> MERMAID_OCEAN = BIOMES.register("mermaid_ocean",
			() -> new MermaidOcean(new Biome.Builder().category(Category.OCEAN).parent((String)null).depth(-1.5F).scale(0.38F)
					.temperature(0.9F).precipitation(RainType.RAIN).downfall(0.6F).waterColor(0x29FF89)
					.waterFogColor(0x29FF89)
					.surfaceBuilder(SurfaceBuilder.DEFAULT, new SurfaceBuilderConfig(Blocks.SAND.getDefaultState(),
							Blocks.SAND.getDefaultState(), Blocks.SAND.getDefaultState()))));

	public static final RegistryObject<Biome> STILL_FOREST = BIOMES.register("still_forest",
			() -> new StillForest(new Biome.Builder().category(Category.FOREST).parent((String)null).depth(0.12F).scale(0.5F)
					.temperature(0.6F).precipitation(RainType.RAIN).downfall(0.4F).waterColor(0x8661F3)
					.waterFogColor(0x8661F3).surfaceBuilder(SurfaceBuilder.DEFAULT,
							new SurfaceBuilderConfig(Blocks.GRASS_BLOCK.getDefaultState(),
									Blocks.DIRT.getDefaultState(), Blocks.COARSE_DIRT.getDefaultState()))));

	private static void registerCoolBiome(Biome biomeIn, Type... typeIn) {
		BiomeDictionary.addTypes(biomeIn, typeIn);
		BiomeManager.addSpawnBiome(biomeIn);
		BiomeManager.addBiome(BiomeManager.BiomeType.COOL, new BiomeManager.BiomeEntry(biomeIn, 100));
	}
	
	private static void registerDesertBiome(Biome biomeIn, Type... typeIn) {
		BiomeDictionary.addTypes(biomeIn, typeIn);
		BiomeManager.addSpawnBiome(biomeIn);
		BiomeManager.addBiome(BiomeManager.BiomeType.DESERT, new BiomeManager.BiomeEntry(biomeIn, 100));
	}
	
	private static void registerIcyBiome(Biome biomeIn, Type... typeIn) {
		BiomeDictionary.addTypes(biomeIn, typeIn);
		BiomeManager.addSpawnBiome(biomeIn);
		BiomeManager.addBiome(BiomeManager.BiomeType.ICY, new BiomeManager.BiomeEntry(biomeIn, 100));
	}
	
	private static void registerWarmBiome(Biome biomeIn, Type... typeIn) {
		BiomeDictionary.addTypes(biomeIn, typeIn);
		BiomeManager.addSpawnBiome(biomeIn);
		BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(biomeIn, 100));
	}
	
	private static void registerDimOnlyBiome(Biome biomeIn, Type... typeIn) {
		BiomeDictionary.addTypes(biomeIn, typeIn);
		BiomeManager.addSpawnBiome(biomeIn);
	}

	public static void registerBiomes() {
		registerWarmBiome(MERMAID_OCEAN.get(), Type.OCEAN, Type.OVERWORLD);
		registerCoolBiome(STILL_FOREST.get(), Type.FOREST, Type.OVERWORLD);
	}
	
	
}
